﻿using System.IO;
using System.Xml;

namespace Google.Translates.WebService
{
    public class LanguageHelper
    {
        public static bool CheckLanguageIsSupport(string languageKey)
        {
            var settingFilePath = System.AppDomain.CurrentDomain.BaseDirectory + "SupportLanguageSetting.xml";
            var doc = new XmlDocument();
            if (File.Exists(settingFilePath))
            {
                doc.Load(settingFilePath);
                var ns = doc.SelectNodes("Settings/Language");
                if(ns!=null)
                {
                    foreach(XmlElement node in ns)
                    {
                        if (node.HasAttribute("Key") && node.GetAttribute("Key").ToLower() == languageKey.ToLower())
                            return true;
                    }
                }
            }
            return false;
        }
    }
}
